package com.hmi.simulatedrive.fragment

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.hmi.simulatedrive.protobuf.HMIPanelModel
import com.hmi.simulatedrive.protobuf.SIMStatusModel

class CarControlFragmentViewModel: ViewModel() {
    val carControlLiveData: MutableLiveData<SIMStatusModel.SimStatus> by lazy { MutableLiveData() }

    fun getHMIPanelBuilder(): HMIPanelModel.HmiPanel.Builder {
        val builder = HMIPanelModel.HmiPanel.newBuilder()
        carControlLiveData.value.let {
            builder
                .setLightOff(it?.lightOff?: false)
                .setLightLeft(it?.lightLeft?: false)
                .setLightRight(it?.lightRight?: false)
                .setLightPosition(it?.lightPosition?: false)
                .setLightFar(it?.lightFar?: false)
                .setLightNear(it?.lightNear?: false)
                .setLightAbs(it?.lightAbs?: false)
                .setLightEsc(it?.lightEsc?: false)
                .setLightHazard(it?.lightHazard?: false)
                .setLightBrake(it?.lightBrake?: false)
                .setLightFog(it?.lightFog?: false)
                .setSwitchACC(if (it?.switchACC == 1) 1 else 0)
                .setSwitchADHuman(if (it?.switchADHuman == 1) 1 else 0)
                .setShiftV(if (it?.shiftV==null) 0 else it.shiftV)
        }
        return builder
    }
}

//class CarControlModel {
//    var light: Int = 0 // 灯光
//    var driveMode: Int = 0 // 驾驶模式
//
//    constructor(light: Int, driveMode: Int) {
//        this.light = light
//        this.driveMode = driveMode
//    }
//}